package com.xsq.testaudio;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;

import androidx.activity.EdgeToEdge;
import androidx.appcompat.app.AppCompatActivity;

import com.xsq.audio.AudioItemData;
import com.xsq.audio.player.PlayManager;
import com.xsq.audio.player.PlayerActivity;
import com.xsq.testaudio.databinding.ActivityMainBinding;

import java.util.ArrayList;
import java.util.List;

public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        EdgeToEdge.enable(this);
        ActivityMainBinding binding = ActivityMainBinding.inflate(getLayoutInflater());
        setContentView(binding.getRoot());
        PlayManager.startAudioService(getApplicationContext(), getDataList1());
        binding.btnPlay.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                PlayManager.playAudioId("1");
                startActivity(new Intent(MainActivity.this, PlayerActivity.class));
            }
        });
    }

    private List<AudioItemData> getDataList1() {
        List<AudioItemData> list = new ArrayList<>();
        AudioItemData audioItemData1 = new AudioItemData();
        audioItemData1.setAudioId("1");
        audioItemData1.setName("音乐1");
        audioItemData1.setPlayUrl("https://storage.googleapis.com/uamp/The_Kyoto_Connection_-_Wake_Up/08_-_Reveal_the_Magic.mp3");
        list.add(audioItemData1);

        AudioItemData audioItemData2 = new AudioItemData();
        audioItemData2.setAudioId("2");
        audioItemData2.setName("音乐2");
        audioItemData2.setPlayUrl("https://storage.googleapis.com/uamp/The_Kyoto_Connection_-_Wake_Up/09_-_Hachiko_The_Faithtful_Dog.mp3");
        list.add(audioItemData2);

        AudioItemData audioItemData3 = new AudioItemData();
        audioItemData3.setAudioId("3");
        audioItemData3.setName("音乐3");
        audioItemData3.setPlayUrl("https://storage.googleapis.com/uamp/The_Kyoto_Connection_-_Wake_Up/02_-_Geisha.mp3");
        list.add(audioItemData3);

        AudioItemData audioItemData4 = new AudioItemData();
        audioItemData4.setAudioId("4");
        audioItemData4.setName("音乐4");
        audioItemData4.setPlayUrl("https://storage.googleapis.com/uamp/The_Kyoto_Connection_-_Wake_Up/03_-_Voyage_I_-_Waterfall.mp3");
        list.add(audioItemData4);

        AudioItemData audioItemData5 = new AudioItemData();
        audioItemData5.setAudioId("5");
        audioItemData5.setName("音乐5");
        audioItemData5.setPlayUrl("https://storage.googleapis.com/uamp/The_Kyoto_Connection_-_Wake_Up/04_-_The_Music_In_You.mp3");
        list.add(audioItemData5);

        AudioItemData audioItemData6 = new AudioItemData();
        audioItemData6.setAudioId("6");
        audioItemData6.setName("音乐6");
        audioItemData6.setPlayUrl("https://storage.googleapis.com/uamp/The_Kyoto_Connection_-_Wake_Up/05_-_The_Calm_Before_The_Storm.mp3");
        list.add(audioItemData6);

        AudioItemData audioItemData7 = new AudioItemData();
        audioItemData7.setAudioId("7");
        audioItemData7.setName("音乐7");
        audioItemData7.setPlayUrl("https://storage.googleapis.com/uamp/The_Kyoto_Connection_-_Wake_Up/06_-_No_Pain_No_Gain.mp3");
        list.add(audioItemData7);

        AudioItemData audioItemData8 = new AudioItemData();
        audioItemData8.setAudioId("8");
        audioItemData8.setName("音乐8");
        audioItemData8.setPlayUrl("https://storage.googleapis.com/uamp/The_Kyoto_Connection_-_Wake_Up/08_-_Reveal_the_Magic.mp3");
        list.add(audioItemData8);

        AudioItemData audioItemData9 = new AudioItemData();
        audioItemData9.setAudioId("9");
        audioItemData9.setName("音乐9");
        audioItemData9.setPlayUrl("https://storage.googleapis.com/uamp/The_Kyoto_Connection_-_Wake_Up/09_-_Hachiko_The_Faithtful_Dog.mp3");
        list.add(audioItemData9);
        return list;
    }

}